package com.tmall.testgen.transfer.startor;

import java.util.Properties;




public class TransferStartorForPlugin {
    
//    public static void main(String[] args) {
//        runCmd("C:/eclipse4.2/plugins/testgen");
//    }
    
    private static boolean isWindows(){
        Properties props=System.getProperties();
        String osName=props.getProperty("os.name");
        if(osName.toLowerCase().contains("windows"))
            return true;
        
        return false;
    } 
    public static void  runCmd(String batPath) {
    	if(isWindows()&&batPath.startsWith("/")||batPath.startsWith("\\"))
    		batPath=batPath.substring(1);	
        try {
            Process ps =null;
            if(isWindows()){
                ps=Runtime.getRuntime().exec(new String[] { "cmd.exe","/C", "java -jar "+batPath+"/transfer.jar"});
            }else{
               ps= Runtime.getRuntime().exec(new String[] { "/bin/sh","-c", "cd "+batPath+";java -jar transfer.jar"});
            }
            //等待中转机充分启动后在继续
             Thread.sleep(1000);
            //无需等待
            //ps.waitFor();
//             String str=null;
//             BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
//
//             while ( (str=bufferedReader.readLine()) != null) System.out.println(str);  
//
//             ps.waitFor();

        } catch (Exception ioe) {
            ioe.printStackTrace();
        }
    }


}
